<?php
	require '../../lib/init.php';
	$gCn=Con();	
	if($_GET['action']=='delete') {
		$objid=(int)$_GET['objid'];		
		$sql='delete from objects where object_id='.$objid.'';
		$gCn->Execute($sql);
		header('Location: viewObjects.php');
	}
?>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>Insert Object</title>
</head>
<body align="center">
	<br><br>
        <a href="insertObject.php">Добави</a>
	<table border="1" width="90%" align="center">
	<tr><th width="40px">ID</th><th>Име</th><th width="40px">Orderby</th><th width="240px" >Actions</th></tr>
		<?php
			$sql='select * from objects order by orderby desc;';
			$gCn->Execute($sql);
			$gCn->MoveFirst();
			while(!$gCn->EOF()) {
				echo '<tr><td>'.$gCn->mRs['object_id'].'</td><td>'.$gCn->mRs['name'].'</td><td>'.$gCn->mRs['orderby'].'</td><td><a href="addToCamp.php?objid='.$gCn->mRs['object_id'].'">CAMP</a> &nbsp;&nbsp;&nbsp;&nbsp;<a href="insertObject.php?objid='.$gCn->mRs['object_id'].'">EDIT</a> &nbsp;&nbsp;&nbsp;&nbsp; <a href="viewObjects.php?action=delete&objid='.$gCn->mRs['object_id'].'">DELETE</a></td></tr>';
				$gCn->MoveNext();
			}
			$gCn->Close();
		?>
	</table>


	
	
	
</body>
</html>